package com.exam.Service;

import com.exam.Entity.Student;
import com.exam.Mapper.StudentMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {
    @Autowired
    private StudentMapper studentMapper;

    public List<Student> findTotal(int page, int size) {

        List<Student> result = studentMapper.findAll();

        return result;
    }

    public List<Student> findAll(int page, int size) {
        //设置分页参数
        PageHelper.startPage(page, size);
        //执行查询
        List<Student> result = studentMapper.findAll();
        // 包装分页结果
        PageInfo<Student> pageInfo = new PageInfo<>(result);

        return pageInfo.getList();
    }


    public Student findById(Integer studentId) {
        return studentMapper.findById(studentId);
    }


    public int deleteById(Integer studentId) {
        return studentMapper.deleteById(studentId);
    }


    public int update(Student student) {
        return studentMapper.update(student);
    }


    public int updatePwd(Student student) {
        return studentMapper.updatePwd(student);
    }


    public int add(Student student) {
        return studentMapper.add(student);
    }
}
